home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / wdj0797.zip / HOWARD.ZIP / IDLEMAIN.CPP < prev    next >
C/C++ Source or Header  |  1997-04-13  |  2KB  |  95 lines

  1. // IdleMain.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "IdleDemo.h"
  6. #include "IdleMain.h"
  7. #include "DemoDlg.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMainDlg dialog
  17.  
  18. CMainDlg::CMainDlg(CWnd* pParent /*=NULL*/)
  19.    : CDialog(CMainDlg::IDD, pParent)
  20. {
  21.    //{{AFX_DATA_INIT(CMainDlg)
  22.       // NOTE: the ClassWizard will add member initialization here
  23.    //}}AFX_DATA_INIT
  24.    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  25. }
  26.  
  27. void CMainDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29.    CDialog::DoDataExchange(pDX);
  30.    //{{AFX_DATA_MAP(CMainDlg)
  31.       // NOTE: the ClassWizard will add DDX and DDV calls here
  32.    //}}AFX_DATA_MAP
  33. }
  34.  
  35. BEGIN_MESSAGE_MAP(CMainDlg, CDialog)
  36.    //{{AFX_MSG_MAP(CMainDlg)
  37.    ON_WM_PAINT()
  38.    ON_WM_QUERYDRAGICON()
  39.    //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CMainDlg message handlers
  44.  
  45. BOOL CMainDlg::OnInitDialog()
  46. {
  47.    CDialog::OnInitDialog();
  48.  
  49.    SetIcon(m_hIcon, TRUE);                 // Set big icon
  50.    SetIcon(m_hIcon, FALSE);                // Set small icon
  51.    
  52.    // TODO: Add extra initialization here
  53.    
  54.    return TRUE;  // return TRUE  unless you set the focus to a control
  55. }
  56.  
  57. // If you add a minimize button to your dialog, you will need the code below
  58. //  to draw the icon.  For MFC applications using the document/view model,
  59. //  this is automatically done for you by the framework.
  60.  
  61. void CMainDlg::OnPaint() 
  62. {
  63.    if (IsIconic())
  64.    {
  65.       CPaintDC dc(this); // device context for painting
  66.  
  67.       SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  68.  
  69.       // Center icon in client rectangle
  70.       int cxIcon = GetSystemMetrics(SM_CXICON);
  71.       int cyIcon = GetSystemMetrics(SM_CYICON);
  72.       CRect rect;
  73.       GetClientRect(&rect);
  74.       int x = (rect.Width() - cxIcon + 1) / 2;
  75.       int y = (rect.Height() - cyIcon + 1) / 2;
  76.  
  77.       // Draw the icon
  78.       dc.DrawIcon(x, y, m_hIcon);
  79.    }
  80.    else
  81.    {
  82.       CDialog::OnPaint();
  83.    }
  84. }
  85.  
  86. HCURSOR CMainDlg::OnQueryDragIcon()
  87. {
  88.    return (HCURSOR) m_hIcon;
  89. }
  90.  
  91. void CMainDlg::OnOK() 
  92. {
  93.    CDemoDlg(this).DoModal();
  94. }
  95.